/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : structs_internal
	/// </summary>
	public class TestPOD2 : IPOD 
    {
        public readonly static Func<TestPOD2> FACTORY = () => new TestPOD2();
		public static Func<TestPOD2> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public float f;
		/// <summary>
        /// 
        /// </summary>
		public double d;
		/// <summary>
        /// 
        /// </summary>
		public long l;
		/// <summary>
        /// 
        /// </summary>
		public bool bx;
		/// <summary>
        /// 
        /// </summary>
		public TestEnum testEnum;
		
		
		
		/*-- constructors --*/
		public TestPOD2() {}
		public TestPOD2(float f, double d, long l, bool bx, TestEnum testEnum) {
			this.f = f;
			this.d = d;
			this.l = l;
			this.bx = bx;
			this.testEnum = testEnum;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_float(f);
            _out.Write_double(d);
            _out.Write_long(l);
            _out.Write_boolean(bx);
            _out.Write_byte((sbyte)testEnum);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            f = _in.Read_float();
            if(!_in.HasRemaining()) return;
            d = _in.Read_double();
            if(!_in.HasRemaining()) return;
            l = _in.Read_long();
            if(!_in.HasRemaining()) return;
            bx = _in.Read_boolean();
            if(!_in.HasRemaining()) return;
            testEnum = (TestEnum)_in.Read_byte();
        }
		
		public TestPOD2 Clone() {
            TestPOD2 o = DynamicFactory();
            o.f = f;
            o.d = d;
            o.l = l;
            o.bx = bx;
            o.testEnum = testEnum;
            return o;
        }
        
        public void Clear() {
            f = default;
            d = default;
            l = default;
            bx = default;
            testEnum = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "TestPOD2 [";
			str += "f=";
			str += f;
			str += ", d=";
			str += d;
			str += ", l=";
			str += l;
			str += ", bx=";
			str += bx;
			str += ", testEnum=";
			str += testEnum;
			str += "]";
			return str;
		}
		
	}
}